# -*- coding: utf-8 -*-
"""
   utils.log
   ~~~~~~~~~

   日志辅助工具
"""
import os,sys
BASE_DIR = os.path.dirname(os.path.abspath(os.curdir))
sys.path.append(BASE_DIR)
import logging


def get_stream_logger(name):
    """获取一个输出到标准输出的 logger"""
    logger = logging.getLogger(name)
    logger.setLevel(logging.DEBUG)

    fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    formatter = logging.Formatter(fmt)

    #handler = logging.StreamHandler()
    #handler.setFormatter(formatter)
    #handler.setLevel(logging.DEBUG)
    #logger.addHandler(handler)
    
    record = logging.FileHandler("falcon_sync.log")
    record.setFormatter(formatter)
    record.setLevel(logging.DEBUG)
    logger.addHandler(record)

    return logger
